package com.pinyoumei.app.adapter;

import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.widget.TextView;

import com.pinyoumei.app.R;
import com.pinyoumei.app.bean.LuckyValueBean;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2021-08-09.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2021-08-09        Administrator             新增Person类
 * 2021-08-09        Administrator             增加sex属性
 */
public class LuckValueAdapter extends BaseQuickAdapter<LuckyValueBean .ResultBean.DataListBean, BaseViewHolder> {
    public LuckValueAdapter(int layoutResId, @Nullable List<LuckyValueBean .ResultBean.DataListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, LuckyValueBean .ResultBean.DataListBean item) {
        helper.setText(R.id.tv_reason,item.getReason());
        helper.setText(R.id.tv_add_time,item.getAdd_time());
        helper.setText(R.id.tv_before_num,"可用幸运值：" + item.getBefore_num());

        TextView tv_change_num = helper.getView(R.id.tv_change_num);
        switch (item.getChange_type()) {
//            动账类型 1增加 2减少
        	case 1:
                tv_change_num.setText("+" +item.getChange_num() );
                tv_change_num.setTextColor(ContextCompat.getColor(mContext,R.color.green_bg2));
        		break;
            case 2:
                tv_change_num.setText("-" +item.getChange_num() );
                tv_change_num.setTextColor(ContextCompat.getColor(mContext,R.color.text_red2));
                break;
        	default:
        		break;
        }
    }
}
